<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/common/common.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>个人信息</title>
<link href="<%=path %>/css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=path %>/third/jqGrid_4.8.2/js/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="<%=path %>/js/common.js"></script>
<script  type="text/javascript" src="<%=path %>/third/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="<%=path %>/third/layer-v1.9.3/layer.js"></script>
<style type="text/css">
.addUsertablelist{
    border:solid 1px #cbcbcb; 
    width:100%; 
    clear:both;}
.addUsertablelist th{
    height:34px; line-height:34px; 
    border-bottom:solid 1px #b6cad2; 
    text-indent:11px; 
    text-align:center;}
.addUsertablelist td{
    line-height:35px; 
    text-indent:11px; 
    border-right: dotted 1px #c7c7c7;}
.tablelinkdelete1{color:red;}
.selectedUsers{
   font-weight:bold;
   float:left; 
   margin-left:12px
}
.newbtn{
  width:85px;
  height:35px; 
  background:url(../images/btnbg.png) no-repeat; 
  font-size:14px;
  font-weight:bold;
  color:#fff; 
  cursor:pointer;
   float:right;
   margin-right:12px;
   margin-top:12px;
   }
.newdiv{
   font-size:14px;
   margin-right:12px;
   margin-left:12px;
   margin-top:12px;
 }
</style>
<script type="text/javascript">
$(function(){		
	//选择全部选项
	      	
   /*******联动开始*********/ 


	 //异步查找所有学院
	function findAllAcademy(domId){
		$.ajax({
			type:"POST",
			dataType:"JSON",
			url:"<%=basePath%>biz/DataJson_FindAllAcademy.action",
			data:{"query":""},
			success:function(data){
			      //  data=JSON.parse(data);
                  //   alert();
					if(null  != data && undefined  !=data){
						for(var i = 0; i < data.length; i++){
							$("#"+domId+"").append("<option value='"+data[i].academyId+"'>"+data[i].academyName+"</option>");
						}
						 
					}
			}
		});
	}
	//异步查找已选学院的专业
	function findAllMajor(academyId , seleMajor){
		$.ajax({
			type:"POST",
			dataType:"JSON",
			url:"<%=basePath%>biz/DataJson_FindAllMajorByAcademy.action",
			data:{"query":JSON.stringify({"academyId":academyId})},
			success:function(data){
		     //   let json = JSON.parse(data)
				$("#"+seleMajor+"").find("option").remove();
				if(null  != data && undefined  != data){
					for(var i = 0; i < data.length; i++){
						$("#"+seleMajor+"").append("<option value='"+data[i].majorId+"'>"+data[i].majorName+"</option>");
					}
					$("#"+seleMajor+"").change();
				}
			}
		});
	}
	//异步查找已选专业的班级
	function findAllClass(majorId , seleClass){
		$.ajax({
			type:"POST",
			dataType:"JSON",
			url:"<%=basePath%>biz/DataJson_FindAllClassByMajor.action",
			data:{"query":JSON.stringify({"majorId":majorId})},
			success:function(data){
			    //    let json=JSON.parse(data)
					$("#"+seleClass+"").find("option").remove();
					if(null  != data && undefined  != data){
						for(var i = 0; i < data.length; i++){
							$("#"+seleClass+"").append("<option value='"+data[i].classId+"'>"+data[i].className+"</option>");
						}									
						 $("#"+seleClass+"").change();
						
					}
			}
		});
	}
	//批量操作-已选学院改变事件
	 $("#selectedAcademy").change(function() {  
	 	findAllMajor($(this).find("option:selected").val(),'selectedMajor');
	}); 
	//批量操作-已选专业改变事件
	 $("#selectedMajor").change(function() {  
	 	findAllClass($(this).find("option:selected").val(),  'selectedClass');
	
	}); 
	


}); 
	/*******联动结束*********/ 
	//查找所有科室

	function findAllStudio(domId){
		$.ajax({
			type:"POST",
			dataType:"JSON",
			url:"<%=basePath%>biz/DataJson_findAllStudio.action",
			data:{"query":""},
			success:function(data){
					if(null  != data && undefined  !=data){
						for(var i = 0; i < data.length; i++){
							$("#"+domId+"").append("<option value='"+data[i].studioId+"'>"+data[i].studioName+"</option>");
						}
						 
					}
			}
		});
	}
	

</script>


<script type="text/javascript">
	//默认选中显示之前用户有的角色名称  
	$(function(){
	
		$(".dfinput1").each(function(){//循环获取所有角色编号 
			roleId = $(this).attr("value");
			$(".userRole").each(function(){//循环获取该用户拥有的角色编号 
				//判断角色表中的角色编号是否与用户拥有的权限编号是否相同
				if(roleId == $(this).attr("value")){
					//若相同,则选中 
					$("#"+roleId).attr("checked",true);
				}
			});
		});
		
		$(".selStudio").each(function(){
			if("${sysUser.userStudio}" == $(this).attr("value")){
				$(this).attr("checked",true);
			}
		
		
		});
		
		//验证用户名 
		$("#userId").blur(function(){//给用户编号添加失去焦点事件
			var url = "/front/SysJson_checkUserName.action";
			var id = $(this).val();//获取用户编号的输入值 
			var inputValue = $(this).attr("userId");//获取原来的用户编号
			id = $.trim(id);
			if(id != inputValue){//如果输入的和原来的不等，校验用户编号
				if(id != ""){
					$.post(url,{"checkName":id},function(data){//发送请求验证用户编号 
						if(data == "true"){//如果返回 true,提示已存在 
							$("#gradeInfo").after("<font color=\"red\">您输入的编号已存在！请重新输入！</font>"); 
						}else{
							$("#gradeInfo").html("");
						}
					},"json");
				}
			}
			$("#gradeInfo").html("");
		});

		
		//验证密码
		
		$("#oldPassword").blur(function(){//给旧密码添加失去焦点事件
			var url = "/front/SysJson_checkUserPasswd.action";
			var pwd = $(this).val();//获取用户输入的密码 
			pwd = $.trim(pwd);
			var rawPwd = $(this).attr("pwdValue");
			if(pwd != ""){
				$.post(url,{"checkName":pwd,"rawPassword":rawPwd},function(data){//发送请求验证输入旧密码
					if(data == "true"){//如果返回 true,提示密码输入有误  
						$("#oldPasswd").html("<font color=\"red\">您输入密码有误！请重新输入！</font>");
						i++;
					}else{
						$("#oldPasswd").html("");
					}
				},"json");
			}
			$("#oldPasswd").html("");
		});
		/**
		已在 jquery validate 中验证
		//验证两次输入的密码是否相同 
		$("#againPassword").blur(function(){
			var againPasswd = $(this).val();//第二次输入的密码
			var newPasswd = $("#newPassword").val();//第一次输入的密码 
			if(againPasswd != newPasswd ){
				$("#againPasswd").html("<font color=\"red\">您两次输入的密码不相同 ！请重新输入！</font>");
			}else{
				$("#againPasswd").html("");
			}
			
		});*/
		
	});
</script>

</head>
<body>

	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="#">首页</a></li>
    <li><a href="#">用户管理</a></li>
    <li><a href="#">基本信息</a></li>
    </ul>
    </div>
    
    <div class="formbody">
    
    <div class="formtitle"><span>用户基本信息</span></div>
    
    <form action="<%= basePath%>/biz/SysUser_edit.action" method="post" id="commonform">
     <input type="hidden" name="sysUser.id" value="${sysUser.id}"/>
     <input name="oldPassword" type="hidden"  value="${sysUser.userPassword }" /> 
     <input type="hidden" name="sysUser.userType" value="${sysUser.userType }"/>
     <input type="hidden" name="sysUser.userId" value="${sysUser.userId}"/>
  
     
    <ul class="forminfo">
    <li><label>姓名</label><input name="sysUser.userName" type="text"  class="dfinput" id="checkName" value="${sysUser.userName}"/><i><font color="#FF0000">*必填</font>不能超过20个字符</i><span id="gradeInfo1"></span></li>
    <li><label>新密码</label><input id="newPassword" name="newPassword" type="password"  class="dfinput" /><i><font color="#FF0000">(若不修改可不填)</font>6-16位字母、数字或下滑线组成</i></li>
    <li><label>确认密码</label><input id="againPassword" name="sysUser.userPassword" type="password"  class="dfinput" /><span id="againPasswd"></span></li>
   
    <li ><label>性别：</label>
        <div class="radio">
        <input type="radio" name="sysUser.userSex" value="1" id="RadioGroup1_1"<c:if test="${sysUser.userSex==1}">checked="checked"</c:if>/>男&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="radio" name="sysUser.userSex" value="0" id="RadioGroup1_0"<c:if test="${sysUser.userSex==0}">checked="checked"</c:if>/>女
        </div>
    </li>
 
    <li><label>邮箱</label><input name="sysUser.userEmail" type="text" class="dfinput" value="${sysUser.userEmail}"></input></li>
   <li><label>手机</label><input name="sysUser.userPhone" type="text" class="dfinput" value="${sysUser.userPhone}"></input></li>
    <li><label><front class="label">学院</front></label><select name="userCollege" id="selectedAcademy" class="scinput">								 
						<option value="">请选择学院 ...</option>		
						<s:iterator value="academyList">
						 <option value="${academyId }" class="selStudio" <c:if test="${sysUser.userCollege==academyName}">selected="selected"</c:if>>${academyName }</option>
						</s:iterator>			
						</select></li> 
    <li><label><front class="label">专业</front></label><select name="userMajor"id="selectedMajor" class="scinput">										 
						<option value="">请选择专业...</option>					
						<s:iterator value="SerMajor">
						 <option value="${majorId }" class="selStudio" <c:if test="${sysUser.userMajor==majorName}">selected="selected"</c:if>>${majorName }</option>
						</s:iterator>	
						</select></li>
	<li><label><front class="label">班级</front></label><select name="userClass"id="selectedClass" class="scinput">										 
						<option value="">请选择班级... </option>		
						<s:iterator value="SerCalss">
						 <option value="${classId }" class="selStudio" <c:if test="${sysUser.userClass==className}">selected="selected"</c:if>>${className }</option>
						</s:iterator>				
						</select></li>
						<c:if test="${sysUser.userType != 0 }">
						<li><label><front class="label">科室</front></label><select name="sysUser.userStudio" id="selectedStudio" class="scinput">	
						<option value="">请选择科室... </option>	
						<s:iterator value="SerStusdio">
						 <option value="${studioName }" class="selStudio" <c:if test="${sysUser.userStudio==studioName}">selected="selected"</c:if>>${studioName }</option>
						</s:iterator>								 
						</select></li></c:if>
	
   

    </ul>
     <ul class="seachform">
     <br/>
     
    </ul>
    <ul class="forminfo">
  <li><label>&nbsp;</label><input name="add_btn" type="submit" class="btn" value="确认保存"/>
 <input name="add_btn" type="button" class="btn" style="background:gray" value="取消" onclick="location.href='javascript:history.go(-1);'"/>
  </li>
    </ul>
    </form>
    <s:iterator value="userRoles" id="w">
     	 <li><input  name="roleId"  type="hidden" class="userRole" value="${roleId}" /></li>
     </s:iterator>
    </div>
	<div class="tip">
    	<div class="tiptop"><span>提示信息</span><a></a></div>
        <div class="tipinfo">
        <span><img src="<%= basePath%>images/ticon.png" /></span>
        <div class="tipright">
        <p>修改失败，您输入的手机号已存在！</p>
        <cite>请重新输入新的手机号！</cite>
        </div>
        </div>
        
        <div class="tipbtn">
        <input name="" type="button"  class="sure" value="确定" />&nbsp;
        <input name="" type="button"  class="cancel" value="取消" />
        </div>
    
    </div>
    
    	<div class="tip1">
    	<div class="tiptop"><span>提示信息</span><a></a></div>
        <div class="tipinfo">
        <span><img src="<%= basePath%>images/ticon.png" /></span>
        <div class="tipright">
        <p>修改失败，您输入的登录名已存在！</p>
        <cite>请重新输入新的登录名！</cite>
        </div>
        </div>
        
        <div class="tipbtn">
        <input name="" type="button"  class="sure1" value="确定" />&nbsp;
        <input name="" type="button"  class="cancel1" value="取消" />
        </div>
        <s:iterator value="userRoles" id="w">
     	 <li><input  name="roleId"  type="hidden" class="userRole" value="${roleId}" /></li>
     </s:iterator>
    </div>
</body>

</html>
